﻿using Mall.Core.Models;
using System;

namespace Mall.Application;

public class UserService : IUserService, ITransient
{
    private readonly IRepository<User> _userRepository;
    public UserService(IRepository<User> userRepository)
    {
        _userRepository=userRepository;
    }
    public bool CheckLogin(LoginDto loginDto)
    {
        var user = _userRepository.FirstOrDefault(x => x.Name == loginDto.UserName);
        if (user == null) { return false; }
        if (MD5Encryption.Compare(loginDto.Password, user.PassWord))
        {
            return true;
        }
        return false;
    }
}
